package ED;

import net.datastructures.Edge;
import net.datastructures.Entry;
import net.datastructures.HashTableMap;
import net.datastructures.InvalidKeyException;
import net.datastructures.Map;
import net.datastructures.NodePositionList;
import net.datastructures.Position;
import net.datastructures.PositionList;
import net.datastructures.Vertex;

/**
 * Implementacion de vertices 
 * 
 * @author Sebastian Giulietti 69032 
 * @author Adrian Sanchez 64251
 *
 * @param <E> Tipo de dato de los vertices
 * @param <M> Tipo de dato de las aristas
 */
public class MyVertex<E, M> implements Vertex<E> {

	PositionList<Edge<M>> adjacencyList;
	E celda;
	Map<Object, Object> map;
	Position<Vertex<E>> pos;
	boolean visitado;

	public MyVertex() {
		adjacencyList = new NodePositionList<Edge<M>>();
		map = new HashTableMap<Object, Object>(10);
	}

	public void addCelda(E o) {
		celda = o;

	}

	public void addEdge(Edge<M> e) {
		adjacencyList.addLast(e);
	}

	public void addPosition(Position<Vertex<E>> position) {
		this.pos = position;
	}

	@Override
	public E element() {
		return celda;
	}

	@Override
	public Iterable<Entry<Object, Object>> entries() {
		return map.entries();
	}

	@Override
	public Object get(Object key) throws InvalidKeyException {
		return map.get(key);
	}

	public PositionList<Edge<M>> getAdjacencyList() {
		return adjacencyList;
	}

	public Position<Vertex<E>> getPos() {
		return pos;
	}

	public boolean getVisitado() {
		return visitado;
	}

	@Override
	public boolean isEmpty() {
		return map.isEmpty();
	}

	@Override
	public Iterable<Object> keys() {
		return map.keys();
	}

	@Override
	public Object put(Object key, Object value) throws InvalidKeyException {
		return map.put(key, value);
	}

	@Override
	public Object remove(Object key) throws InvalidKeyException {
		return map.remove(key);
	}

	public void setVisitado(boolean visitado) {
		this.visitado = visitado;
	}

	@Override
	public int size() {
		return map.size();
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "MyVertex->" + element().toString();
	}

	@Override
	public Iterable<Object> values() {
		return map.values();
	}
}
